package com.by.controller;

import com.by.bean.Enterprise;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.common.valid.ISave;
import com.by.service.EnterpriseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
@Api(tags = "企业管理")
public class EnterpriseController extends BaseController {
    @Autowired
    EnterpriseService enterpriseService;

    @PostMapping("/enterprise")
    @ApiOperation("保存企业")
    public ResultBean save(@Validated(ISave.class) @RequestBody Enterprise enterprise , BindingResult result){
        validate(result);
        int rs = enterpriseService.save(enterprise);
        return saveResult(rs);
    }
}
